package com.taobao.txc.common.config;

import com.taobao.middleware.logger.Level;
import com.taobao.txc.common.LoggerInit;
import com.taobao.txc.common.LoggerWrap;
import com.taobao.txc.common.h;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;

public class o
{
  private static final o b = new o();
  public static boolean a = false;
  private boolean c = true;
  private static String d = null;
  private long e = 0L;
  private static int f = 600000;
  private ExecutorService g = Executors.newSingleThreadExecutor();
  private ReentrantLock h = new ReentrantLock();
  private AtomicInteger i = new AtomicInteger(0);
  private AtomicInteger j = new AtomicInteger(0);
  private StringBuffer k = new StringBuffer();
  private c l = new c("com.taobao.txc.rules.");
  private static String m = null;
  private static ConcurrentHashMap<String, List<Pattern>> n = new ConcurrentHashMap();
  
  public static void a(String paramString)
  {
    d = paramString;
    LoggerInit.logger.a();
  }
  
  public static void a(boolean paramBoolean)
  {
    String str = System.getProperty("txc.console.config");
    try
    {
      if ((!StringUtils.isEmpty(str)) && (!Boolean.parseBoolean(str))) {
        System.out.println("Manually turn off console config");
      } else {
        a = paramBoolean;
      }
    }
    catch (Exception localException)
    {
      a = paramBoolean;
    }
  }
  
  public static o a()
  {
    return b;
  }
  
  public String a(String paramString1, String paramString2, long paramLong)
  {
    if (a) {
      return ConsoleConfig.a().a(paramString1, paramString2);
    }
    return i.b().a(paramString1, paramString2, paramLong);
  }
  
  public String a(String paramString1, String paramString2)
  {
    if (a) {
      return ConsoleConfig.a().a(paramString1, paramString2);
    }
    return i.b().a(paramString1, paramString2);
  }
  
  public void a(String paramString1, String paramString2, m paramm)
  {
    if (a) {
      ConsoleConfig.a().a(paramString1, paramString2, paramm);
    } else {
      this.l.a(paramString1, paramString2, paramm);
    }
  }
  
  public boolean a(String paramString1, String paramString2, String paramString3, com.taobao.txc.common.util.b.a parama)
  {
    if (a) {
      return ConsoleConfig.a().a(paramString1, paramString2, paramString3, parama);
    }
    return i.b().a(paramString1, paramString2, paramString3);
  }
  
  public void a(String paramString1, String paramString2, n paramn)
  {
    if (a) {
      ConsoleConfig.a().a(paramString1, paramString2, paramn);
    } else {
      i.b().b(paramString1, paramString2, paramn);
    }
  }
  
  public String b(String paramString1, String paramString2)
  {
    if (a) {
      return ConsoleConfig.a().b(paramString1, paramString2);
    }
    return this.l.a(paramString1, paramString2);
  }
  
  public boolean b(String paramString)
  {
    String str = b(paramString, "txc.disable");
    return (str != null) && (str.equalsIgnoreCase("true"));
  }
  
  public Integer c(String paramString)
  {
    String str = null;
    str = b(paramString, "txc.clean.days");
    if (StringUtils.isEmpty(str)) {
      return null;
    }
    Integer localInteger = null;
    try
    {
      localInteger = Integer.valueOf(Integer.parseInt(str));
    }
    catch (Exception localException) {}
    return localInteger;
  }
  
  public void a(m paramm)
  {
    a("txc.log.level", d, paramm);
  }
  
  public void b(m paramm)
  {
    a("txc.table.keywords", d, paramm);
  }
  
  public long b()
  {
    try
    {
      String str = b(d, "txc.check.authlevel");
      if (StringUtils.isNumeric(str)) {
        return Long.parseLong(str);
      }
    }
    catch (Exception localException) {}
    return 1L;
  }
  
  public void c(m paramm)
  {
    a("txc.weight", d, paramm);
  }
  
  public void d(m paramm)
  {
    a("txc.degrade.enable", d, paramm);
  }
  
  public static Level d(String paramString)
  {
    if (StringUtils.isEmpty(paramString)) {
      return Level.INFO;
    }
    if (paramString.equalsIgnoreCase("DEBUG")) {
      return Level.DEBUG;
    }
    if (paramString.equalsIgnoreCase("WARN")) {
      return Level.WARN;
    }
    if (paramString.equalsIgnoreCase("ERROR")) {
      return Level.ERROR;
    }
    return Level.INFO;
  }
  
  public int e(String paramString)
  {
    try
    {
      String str = b(paramString, "txc.retry.times");
      if (StringUtils.isNumeric(str)) {
        return Integer.parseInt(str);
      }
    }
    catch (Exception localException) {}
    return 10;
  }
  
  public boolean f(String paramString)
  {
    try
    {
      String str = b(paramString, "txc.mt.default.status");
      if (StringUtils.isEmpty(str)) {
        return true;
      }
      return !str.equalsIgnoreCase("false");
    }
    catch (Exception localException) {}
    return true;
  }
  
  public h g(String paramString)
  {
    h localh = h.a;
    String str = b(paramString, "txc.globallock");
    if ((StringUtils.isNotEmpty(str)) && (StringUtils.isNumeric(str))) {
      localh = h.a(Integer.parseInt(str));
    }
    return localh;
  }
  
  public List<Pattern> h(String paramString)
  {
    String str1 = b(paramString, "txc.table.patterns");
    if (StringUtils.isEmpty(str1)) {
      return null;
    }
    Object localObject = (List)n.get(str1);
    if (localObject == null)
    {
      localObject = new ArrayList();
      String[] arrayOfString1 = str1.split(";");
      for (String str2 : arrayOfString1) {
        ((List)localObject).add(Pattern.compile(str2));
      }
      n.putIfAbsent(str1, localObject);
    }
    return localObject;
  }
  
  public static boolean b(boolean paramBoolean)
  {
    String str = System.getProperty("txc.vip.skip");
    if (StringUtils.isEmpty(str)) {
      return paramBoolean;
    }
    boolean bool = paramBoolean;
    try
    {
      bool = Boolean.parseBoolean(str);
    }
    catch (Exception localException) {}
    return bool;
  }
  
  public boolean c()
  {
    try
    {
      String str = b(d, "txc.analyze.enable");
      if ("true".equalsIgnoreCase(str)) {
        return true;
      }
    }
    catch (Exception localException) {}
    return false;
  }
  
  public int d()
  {
    try
    {
      String str = b(d, "txc.analyze.clean");
      if (StringUtils.isEmpty(str)) {
        return 7;
      }
      return Integer.parseInt(str);
    }
    catch (Exception localException) {}
    return 7;
  }
  
  public void a(String paramString1, String paramString2, int paramInt, com.taobao.txc.common.util.b.a parama)
  {
    if (paramString1 == null) {
      return;
    }
    try
    {
      this.i.incrementAndGet();
      this.j.addAndGet(paramInt);
      if (this.k.length() < 1024) {
        this.k.append('\n').append(Calendar.getInstance().getTime()).append('\t').append(paramString2);
      }
      long l1 = System.currentTimeMillis();
      if ((l1 - this.e > f) && (this.j.get() >= 20)) {
        try
        {
          this.h.lock();
          if ((l1 - this.e > f) && (this.j.get() >= 20))
          {
            this.e = l1;
            String str1 = String.format("com.taobao.txc.alert.%s", new Object[] { paramString1 });
            String str2 = "Alarm times:" + this.i.intValue() + this.k.toString();
            this.k.setLength(0);
            this.i.set(0);
            this.j.set(0);
            this.g.submit(new p(this, str1, str2, parama));
          }
        }
        catch (Exception localException2) {}finally
        {
          this.h.unlock();
        }
      }
    }
    catch (Exception localException1) {}
  }
  
  static
  {
    try
    {
      String str = System.getProperty("txc.force.console");
      if ((!StringUtils.isEmpty(str)) && ((str.equals("1")) || (Boolean.valueOf(str).booleanValue())))
      {
        a = true;
        System.out.println("txc force console config is true");
      }
    }
    catch (Exception localException) {}
  }
}


/* Location:           C:\Users\ibm\Downloads\txc-yun-sample (1)\txc-yun-sample\lib\txc-client-2.0.72.jar
 * Qualified Name:     com.taobao.txc.common.config.o
 * JD-Core Version:    0.7.0.1
 */